{% set chart_data = [] %}

{% macro hierarchy(account_name, begin_date=None, end_date=None, label=None) %}
{% do chart_data.append({
'type': 'hierarchy',
'label': account_name if not label else label,
'data': {
  'modifier': ledger.get_account_sign(account_name),
  'root': ledger.charts.hierarchy(account_name, g.conversion, begin_date, end_date),
},
}) %}
{% endmacro %}

{% macro interval_totals(interval, account_name, label=None, invert=False) %}
{% do chart_data.append({
'type': 'bar',
'label': account_name if not label else label,
'data': ledger.charts.interval_totals(interval, account_name, g.conversion, invert=invert),
}) %}
{% endmacro %}

{% macro events(event_type=None) %}
{% do chart_data.append({
'type': 'scatterplot',
'label': _('Events') if not event_type else _('Event: {}').format(event_type),
'data': ledger.events(event_type),
}) %}
{% endmacro %}

{% macro net_worth(interval) %}
{% do chart_data.append({
'type': 'balances',
'label': _('Net Worth'),
'data': ledger.charts.net_worth(interval, g.conversion),
}) %}
{% endmacro %}

{% macro account_balance(account_name) %}
{% do chart_data.append({
'type': 'balances',
'label': _('Account Balance'),
'data': ledger.charts.linechart(account_name, g.conversion),
}) %}
{% endmacro %}

{% macro commodities() %}
{% for base, quote, prices in ledger.charts.prices() %}
{% do chart_data.append({
'type': 'commodities',
'label': '{0} / {1}'.format(base, quote),
'data': {
  'prices': ledger.prices(base, quote),
  'base': base,
  'quote': quote,
},
}) %}
{% endfor %}
{% endmacro %}
